﻿// 事件基类
public class EventBase
{
    // 事件ID
    protected object m_id = null;

    public EventBase(object id)
    {
        m_id = id;
    }

    // 获取事件ID
    public object ID { get { return m_id; } }

    public virtual void Send()
    {
        Framework.Instance.SendEvent(this);
    }

    public virtual void Post(float delay = .0f)
    {
        Framework.Instance.PostEvent(this, delay);
    }

    public static void SendBase(object id)
    {
        EventBase evt = new EventBase(id);
        evt.Send();
    }

    public static void PostBase(object id, float delay = 0f)
    {
        EventBase evt = new EventBase(id);
        evt.Post(delay);
    }

    public static void SendEvent(EventBase evt)
    {
        if (evt != null)
        {
            evt.Send();
        }
    }

    public static void PostEvent(EventBase evt, float delay = 0f)
    {
        if (evt != null)
        {
            evt.Post(delay);
        }
    }
}